#include "BFPredictor.hpp"
#include "GraphFunctions.hpp"

using namespace std;
using namespace boost;
using namespace TopologicalLearner;

EditOpDist BFPredictor::Predict(const Graph& G) const
{
        Graph kBest;

    if( m_pD == 0 )
        throw std::string("No distribution is attached to this predictor.");

    // For each vertex, check what is the most optimal vertex to add
    std::pair<Iter_t, Iter_t> vp;
    vector<Graph> vTmp;


    for (vp = vertices(G); vp.first != vp.second; ++vp.first)
    {
        Graph gTmp;
        Vertex vNew = add_vertex(gTmp);
        put(vertex_name, gTmp, vNew, get(vertex_name, G, *vp.first));
        vTmp.push_back(gTmp);
    }

    double dBest = -1.0;
    EditOpDist kBestDist;

    // For each vertex, get the edit operation distribution and select the dist that contains
    // the most probable next edit operation.
    for(unsigned int i=0; i < vTmp.size(); i++)
    {
        //-----------
        //EditOpDist kDist = GraphFunctions::GetDistribution(vTmp, *m_pD, i, G, m_iExcludeID);
EditOpDist kDist; //TODO: FIX THIS
        //-----------

        EditOpDist::iterator it;
        for(it = kDist.begin(); it != kDist.end(); it++ )
        {
            if( it->second > dBest )
            {
                kBestDist = kDist;
            }
        }


    }

    //if( IsSubgraphIsomorph(kBest, *m_pEGraph) && !IsSubgraphIsomorph(kBest, *pPartialGraph) && iBest != -1 )
    //    m_bCorrectPrediction = true;

    //vector<Graph> kTmpVec;

    //kTmpVec.push_back(*pPartialGraph);
    // Also add what would be the result of this addition
    //kTmpVec.push_back(kBest);
    //Graph kUnion = GraphUnion(kTmpVec);


    return kBestDist;
}
